import { ajax } from '../libs/ajax.js';
import { tools } from '../libs/tools.js';

let div_title = document.getElementById('div_title');
let div_source = document.getElementById('div_source');
let div_content = document.getElementById('div_content');
let title = document.querySelector('title');

let bid = location.search.replace('?bid=','')

ajax.get(`/crud/billboard/${bid}`,{},(data)=>{
  if (!data.success) {
    alert(data.message);
    return;
  }
  let bbd = data.data;
  div_title.innerHTML = bbd.title;

  div_source.innerHTML = `
  ${bbd.username}-${tools.formatDate(bbd.lastupdate)}
`;
div_content.innerHTML = bbd.content;
title.innerHTML = bbd.title;
})